package code08_三大特征.home4;

import java.util.Scanner;

public class 作业4 {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		Student[] students = new Student[100];
		String str;
		System.out.println("请录入学生信息，最多不能超过一百个。");
		int i=0;
		while (true) {
			System.out.println("请输入第" + (i + 1) + "个学生的信息（录入姓名时输入q退出程序）：");
			System.out.print("姓名:");
			str = input.next();
			if (str.equals("q")) {
				break;
			}
			students[i] = new Student();
			students[i].setName(str);
			System.out.print("年龄:");
			students[i].setAge(input.nextInt());
			System.out.print("性别:");
			students[i].setSex(input.next());
			System.out.print("学号:");
			students[i].setNum(input.nextInt());
			i++;
		}
		System.out.println("姓名\t年龄\t性别\t学号");
		for (int j = 0; j < i; j++) {
			Student stu  = students[j];
			if (stu.getAge() >= 18)
				System.out.println(stu.getName() + "\t" + stu.getAge() + "\t" + stu.getSex() + "\t" + stu.getNum() + "\t");
		}
	}
}

class Student {
	private String name;
	private String sex;
	private int age, num;

	public void study() {
		System.out.println(name + "学习中");
	}

	public Student() {
		super();
	}

	public Student(String name, String sex, int age, int num) {
		super();
		this.name = name;
		this.sex = sex;
		this.age = age;
		this.num = num;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

	public int getNum() {
		return num;
	}

	public void setNum(int num) {
		this.num = num;
	}

}
